package controller;

import java.io.IOException;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

@WebServlet("/RecordFixSg")

public class RecordFixSg extends HttpServlet {
	private static final long serialVersionUID = 1L;
	 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		HttpSession session = request.getSession();
        String userId = (String) session.getAttribute("sg"); // 假设用户ID存储在名为"student"的session属性中
 
        if (userId != null) {
            // 重定向到studentFixRecord.jsp，并通过请求参数传递用户ID
            response.sendRedirect("View_fix/FixRecordSg.jsp?userId=" + userId);
        } else {
            // 如果用户ID不存在，重定向到登录页面或错误页面
            response.sendRedirect("login.jsp"); 
        }
    }
}
